using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("Movement")]
	[AgentType(typeof(Transform))]
	public class MoveAway : ActionTask
	{
		[RequiredField]
		public BBGameObject target;

		public BBFloat speed = new BBFloat
		{
			value = 2f
		};

		public BBFloat stopDistance = new BBFloat
		{
			value = 3f
		};

		public bool repeat;

		protected override void OnExecute()
		{
			Move();
		}

		protected override void OnUpdate()
		{
			Move();
		}

		private void Move()
		{
			if ((base.agent.transform.position - target.value.transform.position).magnitude < stopDistance.value)
			{
				base.agent.transform.position = Vector3.MoveTowards(base.agent.transform.position, target.value.transform.position, (0f - speed.value) * Time.deltaTime);
			}
			if (!repeat)
			{
				EndAction();
			}
		}
	}
}
